package tt;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;
import com.google.appengine.api.users.UserService;
import com.google.appengine.api.users.UserServiceFactory;

import tt.Vuser;

public class Newuser extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		UserService userService = UserServiceFactory.getUserService();
		User user = userService.getCurrentUser();
		String owner = user.getUserId().toString().trim();

		String name = req.getParameter("name");
		String apellido1 = req.getParameter("apellido1");
		String apellido2 = req.getParameter("apellido2");
		String pass = req.getParameter("pass");
		String tipo = req.getParameter("tipo");
		Appuser usertoadd = new Appuser(owner, name, apellido1, apellido2, tipo, pass);
		Vuser.INSTANCE.add(usertoadd);
		resp.sendRedirect("/index.jsp");
	}
}
